package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/06 22:47
 **/
public class Day4_11_Offer65_ConstructArr {
    class Solution {
        public int[] constructArr(int[] a) {
            int n = a.length, product = 1;
            int[] b = new int[n];
            for(int i = 0; i < n; ++i){
                b[i] = product;
                product *= a[i];
            }
            product = 1;
            for(int i = n-1; i >= 0; --i){
                b[i] *= product;
                product *= a[i];
            }
            return b;
        }
    }
}